#ifndef POPUP_ITEM_H
#define POPUP_ITEM_H

#include <QStyledItemDelegate>
#include <QHash>

class PopupItemDelegate: public QStyledItemDelegate
{
    Q_OBJECT
public:
    explicit PopupItemDelegate(QObject *parent);

    virtual ~PopupItemDelegate();

    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

    QWidget *createEditor(QWidget *parent,const QStyleOptionViewItem &,const QModelIndex &) const;

    void setEditorData(QWidget *editor, const QModelIndex &index) const override;
    void setModelData(QWidget *editor,QAbstractItemModel *model,const QModelIndex &index) const override;

    void updateEditorGeometry(QWidget *editor,
                              const QStyleOptionViewItem &option,
                              const QModelIndex &index) const override;

    virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;

signals:
    void clickItem(const QModelIndex &index);

protected:
    virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;

private:
    QSize m_countSize;

    QPoint curPos;
};


#endif // POPUP_ITEM_H
